package com.goldplusgold.tradedelay.app.home.live;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.goldplusgold.imageloader.lib.IShow;
import com.goldplusgold.tradedelay.app.R;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/7/24.
 */

public class ColumnIntroAnalystsItem {
    ImageView live_column_layout_icon;
    TextView live_column_layout_name;
    TextView live_column_layout_intro;
    LinearLayout live_column_layout_tags;
    Context context;
    RelativeLayout rootView;
    public ColumnIntroAnalystsItem(Context context){
        this.context = context;
        initView();
    }

    private void initView(){
        rootView = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.live_column_analysts_item,null);
        live_column_layout_icon = (ImageView)rootView.findViewById(R.id.live_column_layout_icon);
        live_column_layout_name = (TextView)rootView.findViewById(R.id.live_column_layout_name);
        live_column_layout_intro = (TextView)rootView.findViewById(R.id.live_column_layout_intro);
       // live_column_layout_tags = (LinearLayout)rootView.findViewById(R.id.live_column_layout_tags);
    }

    public RelativeLayout getRootView(){
        return rootView;
    }

    public void setIcon(String url){
        if(!TextUtils.isEmpty(url)){
            IShow.getInstance().showCircle(context,url,live_column_layout_icon);
        }
    }

    public void setName(String name){
        if(!TextUtils.isEmpty(name)){
            if(live_column_layout_name != null){
                live_column_layout_name.setText(name);
            }
        }
    }

    public void setIntro(String intro){
        if(!TextUtils.isEmpty(intro)){
            if(live_column_layout_intro != null){
                live_column_layout_intro.setText(intro);
            }
        }
    }

    public void setTags(String tags){
        if(tags == null || "".equals(tags)){
            return;
        }
        String [] tgs = tags.split(",");
        TextView view;
        for(String tag:tgs){
            view = new TextView(context);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
            params.gravity = Gravity.CENTER_VERTICAL;
            params.rightMargin = context.getResources().getDimensionPixelSize(R.dimen.list_video_item_margin_bottom);
            params.bottomMargin = context.getResources().getDimensionPixelSize(R.dimen.list_video_item_margin_bottom);
            view.setText(tag);
            view.setBackgroundResource(R.drawable.shape_textview);
            view.setGravity(Gravity.CENTER_VERTICAL);
            view.setTextColor(context.getResources().getColor(R.color.color_gold));
            live_column_layout_tags.addView(view,params);
        }
    }

}
